<?php

namespace App\HttpController;
use EasySwoole\Http\AbstractInterface\AbstractRouter;
use FastRoute\RouteCollector;
use EasySwoole\Http\Request;
use EasySwoole\Http\Response;
class Router extends AbstractRouter
{
    function initialize(RouteCollector $routeCollector)
    {
        $this->setGlobalMode(true);



        //支持订阅号大版本更新
        $routeCollector->addGroup('/v1',function (RouteCollector $routeCollector){

            //获取服务器时间戳
            $routeCollector->post('/getServerTimestamp','/Api/V1/Index/getServerTimestamp');
            $routeCollector->post('/clearWatermark','/Api/V1/Video/clearWatermark');


        });


        //后台
        $routeCollector->addGroup('/admin',function (RouteCollector $routeCollector){




            
        });

        $this->setRouterNotFoundCallBack(function (Request $request,Response $response){
            $response->withHeader('Content-type','application/json;charset=utf-8');
            $response->withStatus(500);
            $response->write(json_encode(['code'=> '500','msg'=> "不小心迷路了!",'data'=> []]));
            $response->end();
            return;
        });
    }
}